﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace SystemCenterSoa.Repository.Migrations
{
    public partial class to : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "deptIds",
                table: "Staff");

            migrationBuilder.DropColumn(
                name: "staffNumber",
                table: "Staff");

            migrationBuilder.RenameColumn(
                name: "deptNumber",
                table: "Department",
                newName: "depDepartName");

            migrationBuilder.AlterColumn<string>(
                name: "technologyId",
                table: "Staff",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<string>(
                name: "roleId",
                table: "Staff",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<string>(
                name: "professionalId",
                table: "Staff",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<string>(
                name: "managementId",
                table: "Staff",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<string>(
                name: "majorId",
                table: "Staff",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AddColumn<int>(
                name: "de_id",
                table: "leave_apply",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "de_id",
                table: "field_apply",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "de_id",
                table: "evection_apply",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AlterColumn<string>(
                name: "deptTypeId",
                table: "Department",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<string>(
                name: "structural_type_id",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<int>(
                name: "original_amount",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "contractual_permissible_state",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "build_type_id",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AddColumn<string>(
                name: "create_name",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "create_time",
                table: "contract",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<int>(
                name: "drawing_num_yet",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "signed_area",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "signed_idx",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "signed_limit",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "signed_name",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "signed_notes",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "signed_status",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "trip_num_yet",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AlterColumn<DateTime>(
                name: "uploadTime",
                table: "Accessory",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.CreateTable(
                name: "company_activities_apply",
                columns: table => new
                {
                    gshd_id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    gshd_reason = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    gshd_start_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    gshd_end_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    gshd_kqtj = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    gshd_note = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    cc_mileage = table.Column<int>(type: "int", nullable: false),
                    de_id = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_company_activities_apply", x => x.gshd_id);
                });

            migrationBuilder.CreateTable(
                name: "department_activity_apply",
                columns: table => new
                {
                    bmhd_id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    bmhd_reason = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    bmhd_start_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    bmhd_end_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    bmhd_kqtj = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    bmhd_note = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    de_id = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_department_activity_apply", x => x.bmhd_id);
                });

            migrationBuilder.CreateTable(
                name: "not_clock_apply",
                columns: table => new
                {
                    wdk_id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    wdk_start_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    wdk_end_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    wdk_why = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    de_id = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_not_clock_apply", x => x.wdk_id);
                });

            migrationBuilder.CreateTable(
                name: "work_overtime_leave_apply",
                columns: table => new
                {
                    jblg_id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    jblg_reason = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    jblg_start_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    jblg_end_date = table.Column<DateTime>(type: "datetime2", nullable: false),
                    jblg_kqtj = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
                    jblg_note = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    de_id = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_work_overtime_leave_apply", x => x.jblg_id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "company_activities_apply");

            migrationBuilder.DropTable(
                name: "department_activity_apply");

            migrationBuilder.DropTable(
                name: "not_clock_apply");

            migrationBuilder.DropTable(
                name: "work_overtime_leave_apply");

            migrationBuilder.DropColumn(
                name: "de_id",
                table: "leave_apply");

            migrationBuilder.DropColumn(
                name: "de_id",
                table: "field_apply");

            migrationBuilder.DropColumn(
                name: "de_id",
                table: "evection_apply");

            migrationBuilder.DropColumn(
                name: "create_name",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "create_time",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "drawing_num_yet",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "signed_area",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "signed_idx",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "signed_limit",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "signed_name",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "signed_notes",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "signed_status",
                table: "contract");

            migrationBuilder.DropColumn(
                name: "trip_num_yet",
                table: "contract");

            migrationBuilder.RenameColumn(
                name: "depDepartName",
                table: "Department",
                newName: "deptNumber");

            migrationBuilder.AlterColumn<int>(
                name: "technologyId",
                table: "Staff",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "roleId",
                table: "Staff",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "professionalId",
                table: "Staff",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "managementId",
                table: "Staff",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "majorId",
                table: "Staff",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AddColumn<string>(
                name: "deptIds",
                table: "Staff",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "staffNumber",
                table: "Staff",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "deptTypeId",
                table: "Department",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<int>(
                name: "structural_type_id",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "original_amount",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<string>(
                name: "contractual_permissible_state",
                table: "contract",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<int>(
                name: "build_type_id",
                table: "contract",
                type: "int",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(string),
                oldType: "nvarchar(max)",
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "uploadTime",
                table: "Accessory",
                type: "nvarchar(max)",
                nullable: true,
                oldClrType: typeof(DateTime),
                oldType: "datetime2");
        }
    }
}
